package 表达式求值;

import java.util.Scanner;
import java.util.Stack;

public class Main {
    static int MOD = 10000;
    static Stack<Integer> nums = new Stack<>();
    static Stack<Character> ops = new Stack<>();

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        String s = in.next();
        for (int i = 0; i < s.length(); i++) {
            char ch = s.charAt(i);
            if (ch >= '0' && ch <= '9') {
                int val = 0;
                while (i < s.length() && s.charAt(i) >= '0' && s.charAt(i) <= '9') {
                    val = val * 10 + (s.charAt(i) - '0');
                    i++;
                }
                i--;
                nums.add(val % MOD);
            } else if (ch == '+') {
                while (!ops.isEmpty()) {
                    eval();
                }
                ops.add(ch);
            } else if (ch == '*') {
                while (!ops.isEmpty() && ops.peek() == '*') {
                    eval();
                }
                ops.add(ch);
            }
        }
        while (!ops.isEmpty()) {
            eval();
        }
        System.out.println(nums.pop());
    }

    private static void eval() {
        int b = nums.pop();
        int a = nums.pop();
        char c = ops.pop();
        if (c == '+') {
            nums.add((a + b) % MOD);
        } else {
            nums.add(a * b % MOD);
        }
    }
}
